package cn.caterer.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;

import cn.caterer.pojo.Employee;
import cn.caterer.service.LoginService;
@Controller
public class LoginController {
	@Resource
	private LoginService loginService;
	@PostMapping("/login")
	public String login(Employee employee,HttpSession session) {
		System.out.println("000000000");
		Employee emp=null;
		try {
			emp=loginService.login(employee);
			System.out.println("sql正常执行");
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
			System.out.println("sql没有正常执行");
			return "fail";
		}
		if(emp!=null) {
			session.setAttribute("employee", emp);
			return "success";
		}else {
			return "fail";
		}
	}

}
